package com.voice.server.connection;

import com.voice.core.connection.impl.SocketChannelConnectionImpl;
import lombok.Data;

import java.io.IOException;
import java.net.InetSocketAddress;


@Data
public class SdkConnection extends SocketChannelConnectionImpl {

    private String userId;
    private String appKey;
    private String host;
    private Integer port;

    public SdkConnection(SocketChannelConnectionImpl connection,String userId,String appKey) throws IOException {
        super(connection.getCurrentStreamId().get());
        this.socketChannelAdapter=connection.getSocketChannelAdapter();
        InetSocketAddress socketAddress= (InetSocketAddress) this.socketChannelAdapter.getSocketChannel().getRemoteAddress();
        this.host=socketAddress.getHostName();
        this.socketChannelAdapter.setConnection(this);
        this.userId = userId;
        this.appKey = appKey;
    }

}
